<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
<th:block th:include="include :: header('篮球详情')" />
</head>
<body class="white-bg">
	<div class="ibox-content">
		<table class="table table-bordered">
			<tr>
				<td colspan="6" style="text-align: center;" id="title"></td>
			</tr>
			<tr>
				<td style="text-align: center;"></td>
				<td style="text-align: center;">竞彩</td>
				<td style="text-align: center;">HG</td>
				<td style="text-align: center;">总下注</td>
				<td style="text-align: center;">利润</td>
			</tr>
			<tr>
				<td style="text-align: center;">赔率</td>
				<td style="text-align: center;font-weight: bold;" id="jc"></td>
				<td style="text-align: center;font-weight: bold;" id="hg"></td>
				<td style="text-align: center;"></td>
				<td style="text-align: center;"></td>
			</tr>
			<tr>
				<td style="text-align: center;">下注率</td>
				<td style="text-align: center;width: 10px;"><input type="number" id="betAmount" /></td>
				<td style="text-align: center;color: red;font-weight: bold;" id="betMoneyPeriphery"></td>
				<td style="text-align: center;color: red;font-weight: bold;" id="TotalExpense"></td>
				<td style="text-align: center;color: red;font-weight: bold;" id="profit"></td>
			</tr>
		</table>
	</div>
	<th:block th:include="include :: footer" />
	<script type="text/javascript">
		var dggpDetail = localStorage.getItem("dggpDetail");
		if(dggpDetail){
			dggpDetail = JSON.parse(dggpDetail);
			$(function(){
				$('#title').text(dggpDetail.title);
				$('#jc').text(dggpDetail.jc);
				$('#hg').text(dggpDetail.hg);
				$('#betAmount').val(dggpDetail.betAmount);
				$('#betMoneyPeriphery').text(parseFloat(dggpDetail.betMoneyPeriphery).toFixed(2)+'元');
				$('#TotalExpense').text(parseFloat(dggpDetail.TotalExpense).toFixed(2)+'元');
				$('#profit').text(parseFloat(dggpDetail.profit).toFixed(2)+'元');
				$('#betAmount').bind('input propertychange', function() {
					console.log($(this).val());
					var betAmount = $(this).val();
					if(!betAmount) {
						betAmount = 1;
					}
					var betMoneyPeriphery = (dggpDetail.betMoneyPeriphery * (betAmount / dggpDetail.betAmount)).toFixed(2);
					$('#betMoneyPeriphery').text(betMoneyPeriphery+'元');
					var TotalExpense = ((parseFloat(betAmount ? betAmount : 0) + parseFloat(dggpDetail.betMoneyPeriphery)) * (betAmount / dggpDetail.betAmount)).toFixed(2);
					$('#TotalExpense').text(TotalExpense+'元');
					var profit = (dggpDetail.profit * (betAmount / dggpDetail.betAmount)).toFixed(2);
					$('#profit').text(profit+'元');
					$(this).val(betAmount);
				});
			});
		}
	</script>
</body>
</html>
